<?php

/*
 * Copyright 2008 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#namespace tehframework\annotations\parsers\state;

#use tehframework\annotations\parsers\ConstantValueParserImpl;
#use tehframework\annotations\parsers\AnnotationParserImpl;
#use tehframework\annotations\parsers\ArrayParserImpl;
#use tehframework\annotations\parsers\state\processors;

class ParserState
{
	const UNKNOWN              = -1;
	const DOCBLOCK             = 0;
	const SHORT_DESCRIPTION    = 1;
	const LONG_DESCRIPTION     = 2;
	const TAG                  = 3;
	const TAG_NAME             = 4;
	const TAG_VALUE            = 5;
	const ANNOTATION           = 6;
	const ANNOTATION_NAME      = 7;
	const ANNOTATION_TYPE      = 8;
	const ANNOTATION_PARAMETER = 9;
	const ANNOTATION_VALUE     = 10;
	
	protected function __construct()
	{}
	
	public static function getNameFromValue($value)
	{
		switch ($value)
		{
			case self::DOCBLOCK:
				return 'ParserState::DOCBLOCK';
			
			case self::SHORT_DESCRIPTION:
				return 'ParserState::SHORT_DESCRIPTION';
			
			case self::LONG_DESCRIPTION:
				return 'ParserState::LONG_DESCRIPTION';
			
			case self::TAG:
				return 'ParserState::TAG';
			
			case self::TAG_NAME:
				return 'ParserState::TAG_NAME';
			
			case self::TAG_VALUE:
				return 'ParserState::TAG_VALUE';
			
			case self::ANNOTATION:
				return 'ParserState::ANNOTATION';
			
			case self::ANNOTATION_NAME:
				return 'ParserState::ANNOTATION_NAME';
			
			case self::ANNOTATION_TYPE:
				return 'ParserState::ANNOTATION_TYPE';
			
			case self::ANNOTATION_PARAMETER:
				return 'ParserState::ANNOTATION_PARAMETER';
			
			case self::ANNOTATION_VALUE:
				return 'ParserState::ANNOTATION_VALUE';
			
			default:
				return 'UNKNOWN';
		}
	}
	
	/**
	 * @return array<ParserState::*,StateProcessor>
	 */
	public static function createStateToProcessorMap()
	{
		$constantValueParser = new ConstantValueParserImpl();
		$arrayParser         = new ArrayParserImpl($constantValueParser);
		$annotationParser    = new AnnotationParserImpl($arrayParser);
		
		$arrayParser->withAnnotationParser($annotationParser);
		
		return array
		(
			self::DOCBLOCK              => new /*processors\*/DocBlockProcessor(),
			self::SHORT_DESCRIPTION     => new /*processors\*/ShortDescriptionProcessor(),
			self::LONG_DESCRIPTION      => new /*processors\*/LongDescriptionProcessor(),
			self::TAG                   => new /*processors\*/TagProcessor(),
			self::TAG_NAME              => new /*processors\*/TagNameProcessor(),
			self::TAG_VALUE             => new /*processors\*/TagValueProcessor(),
			self::ANNOTATION            => new /*processors\*/AnnotationProcessor(),
			self::ANNOTATION_NAME       => new /*processors\*/AnnotationNameProcessor(),
			self::ANNOTATION_TYPE       => new /*processors\*/AnnotationTypeProcessor(),
			self::ANNOTATION_PARAMETER  => new /*processors\*/AnnotationParameterProcessor(),
			self::ANNOTATION_VALUE      => new /*processors\*/AnnotationValueProcessor($arrayParser),
		);
	}
}